<template>
  <div class="dataList">
    <van-list :finished="false">
      <van-cell v-for="item in displayCinemas" :key="item" :title="item.key" />
    </van-list>
  </div>
</template>

<script lang="ts" setup>
import { getSearchList } from '@/api'
// 输入框 的内容
const textWord = ref<string>('')
// 输入输入请求的内容
const cinemas = ref<SearchList[]>([])

// 搜索结果
const displayCinemas = computed(() => {
  if (!textWord.value) {
    return []
  }
  // @ts-ignore
  return cinemas.value[0].filter((item) => {
    return item.key.includes(textWord.value)
  })
})

// 请求获取数据
watchEffect(async () => {
  const abc = await getSearchList()
  cinemas.value = [abc]
  // console.log(cinemas.value)
  // console.log(displayCinemas)
})

defineExpose({
  displayCinemas
})


</script>

<style scoped></style>
